package com.mabs.ground.client.module.mod1.activity;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.mabs.ground.client.common.ClientFactory;
import com.mabs.ground.client.common.MyAbstractActivity;
import com.mabs.ground.client.module.mod1.place.HelloPlace;
import com.mabs.ground.client.module.mod1.view.HelloView;
import com.mabs.ground.client.module.mod2.place.GoodbyePlace;

/**
 * @author <a href="Email: mohamedarbi.benslimane@allence-tunisie.com">Ben
 *         Slimane Arbi</a>
 * @version 1.0
 * @since 1.0 - 25 juil. 2014 - 19:43:11
 */
public class HelloActivity extends MyAbstractActivity {

	private String name;
	private HelloView display;

	public HelloActivity(HelloPlace place, ClientFactory clientFactory) {
		super(clientFactory);
		this.name = place.getHelloName();
		display = getClientFactory().getHelloView();
	}

	/**
	 * Invoked by the ActivityManager to start a new Activity
	 */
	public void start(AcceptsOneWidget containerWidget, EventBus eventBus) {
		display.setName(name);
		display.getGoodbyeLinkClickHandlers().addClickHandler(
				new ClickHandler() {

					public void onClick(ClickEvent arg0) {
						getPlaceController().goTo(new GoodbyePlace("GoodBye"));
					}
				});
		getClientFactory().getMain().setMainPanel(display.asWidget());

	}

}
